package com.cyh.pangu.offer;

import java.util.Stack;

/**
 * @author cuiyh9
 * @date 2020/8/27
 */
public class Offer09 {

    Stack<Integer> firstStack = new Stack<>();
    Stack<Integer> secondStack = new Stack<>();

    public void appendTail(int value) {
        firstStack.push(value);
    }

    public int deleteHead() {
        if (firstStack.isEmpty() && secondStack.isEmpty()) {
            return -1;
        }
        if (!secondStack.isEmpty()) {
            return secondStack.pop();
        } else {
            while (!firstStack.isEmpty()) {
                secondStack.push(firstStack.pop());
            }
        }
        return secondStack.pop();
    }
}
